package api

import (
	"gitee.com/gopher2011/gva/server/dao"
	"gitee.com/gopher2011/gva/server/util"
	"github.com/gin-gonic/gin"
	"io/ioutil"
)

var Exa = exaApi{}

type exaApi struct {}

// @Summary 断点续传到服务器
// @Router /fileUploadAndDownload/breakpointContinue [post]
func (it *exaApi)BreakpointContinue(c *gin.Context){
	fileMd5 := c.Request.FormValue("fileMd5")
	fileName := c.Request.FormValue("fileName")
	chunkMd5 := c.Request.FormValue("chunkMd5")
	chunkNumber  := c.Request.FormValue("chunkNumber")
	chunkTotal := c.Request.FormValue("chunkTotal")
	_, FileHeader, err := c.Request.FormFile("file") //接收上传的文件
	if err != nil {
		dao.Log.Error("接收文件失败!")
		FailWithMessage(c,"接收文件失败")
		return
	}
	f,err := FileHeader.Open()
	if err != nil {
		dao.Log.Error("文件读取失败!")
		FailWithMessage(c,"文件读取失败")
		return
	}
	defer f.Close()
	conn,_ := ioutil.ReadAll(f)
	if !util.CheckMd5(conn,chunkMd5) {
		dao.Log.Error("检查md5失败!")
		FailWithMessage(c,"检查md5失败")
		return
	}





}


